package registnet.dao;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;

  
  
/**
 * This class was autogenerated by Torque on:
 *
 * [Tue Jun 30 14:38:16 PDT 2009]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Course
 */
public abstract class BaseCourse extends BaseObject
{
    /** The Peer class */
    private static final CoursePeer peer =
        new CoursePeer();

        
    /** The value for the courseId field */
    private int courseId;
      
    /** The value for the courseCode field */
    private String courseCode;
      
    /** The value for the courseName field */
    private String courseName;
      
    /** The value for the courseDescription field */
    private String courseDescription;
      
    /** The value for the units field */
    private int units;
                                          
    /** The value for the offered field */
    private int offered = 0;
      
    /** The value for the semesterOffered field */
    private String semesterOffered;
      
    /** The value for the prerequisite field */
    private String prerequisite;
      
    /** The value for the lectureHoursPerWeek field */
    private int lectureHoursPerWeek;
      
    /** The value for the minimumNumberOfLectureStudents field */
    private int minimumNumberOfLectureStudents;
      
    /** The value for the maximumNumberOfLectureStudents field */
    private int maximumNumberOfLectureStudents;
                                          
    /** The value for the hasLaboratory field */
    private int hasLaboratory = 1;
      
    /** The value for the laboratoryHoursPerWeek field */
    private int laboratoryHoursPerWeek;
      
    /** The value for the minimumNumberOfLaboratoryStudents field */
    private int minimumNumberOfLaboratoryStudents;
      
    /** The value for the maximumNumberOfLaboratoryStudents field */
    private int maximumNumberOfLaboratoryStudents;
      
    /** The value for the unitId field */
    private int unitId;
  
    
    /**
     * Get the CourseId
     *
     * @return int
     */
    public int getCourseId()
    {
        return courseId;
    }

                                              
    /**
     * Set the value of CourseId
     *
     * @param v new value
     */
    public void setCourseId(int v) throws TorqueException
    {
    
                  if (this.courseId != v)
              {
            this.courseId = v;
            setModified(true);
        }
    
          
                                  
        // update associated CurriculumCourse
        if (collCurriculumCourses != null)
        {
            for (int i = 0; i < collCurriculumCourses.size(); i++)
            {
                ((CurriculumCourse) collCurriculumCourses.get(i))
                    .setCourseId(v);
            }
        }
                                          
        // update associated SectionConfiguration
        if (collSectionConfigurations != null)
        {
            for (int i = 0; i < collSectionConfigurations.size(); i++)
            {
                ((SectionConfiguration) collSectionConfigurations.get(i))
                    .setCourseId(v);
            }
        }
                                          
        // update associated PlanOfCourseWork
        if (collPlanOfCourseWorks != null)
        {
            for (int i = 0; i < collPlanOfCourseWorks.size(); i++)
            {
                ((PlanOfCourseWork) collPlanOfCourseWorks.get(i))
                    .setCourseId(v);
            }
        }
                                          
        // update associated Grade
        if (collGrades != null)
        {
            for (int i = 0; i < collGrades.size(); i++)
            {
                ((Grade) collGrades.get(i))
                    .setCourseId(v);
            }
        }
                                          
        // update associated CourseDemand
        if (collCourseDemands != null)
        {
            for (int i = 0; i < collCourseDemands.size(); i++)
            {
                ((CourseDemand) collCourseDemands.get(i))
                    .setCourseId(v);
            }
        }
                                          
        // update associated CourseOffering
        if (collCourseOfferings != null)
        {
            for (int i = 0; i < collCourseOfferings.size(); i++)
            {
                ((CourseOffering) collCourseOfferings.get(i))
                    .setCourseId(v);
            }
        }
                                          
        // update associated RecommendedCourse
        if (collRecommendedCourses != null)
        {
            for (int i = 0; i < collRecommendedCourses.size(); i++)
            {
                ((RecommendedCourse) collRecommendedCourses.get(i))
                    .setCourseId(v);
            }
        }
                      }
  
    /**
     * Get the CourseCode
     *
     * @return String
     */
    public String getCourseCode()
    {
        return courseCode;
    }

                        
    /**
     * Set the value of CourseCode
     *
     * @param v new value
     */
    public void setCourseCode(String v) 
    {
    
                  if (!ObjectUtils.equals(this.courseCode, v))
              {
            this.courseCode = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the CourseName
     *
     * @return String
     */
    public String getCourseName()
    {
        return courseName;
    }

                        
    /**
     * Set the value of CourseName
     *
     * @param v new value
     */
    public void setCourseName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.courseName, v))
              {
            this.courseName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the CourseDescription
     *
     * @return String
     */
    public String getCourseDescription()
    {
        return courseDescription;
    }

                        
    /**
     * Set the value of CourseDescription
     *
     * @param v new value
     */
    public void setCourseDescription(String v) 
    {
    
                  if (!ObjectUtils.equals(this.courseDescription, v))
              {
            this.courseDescription = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Units
     *
     * @return int
     */
    public int getUnits()
    {
        return units;
    }

                        
    /**
     * Set the value of Units
     *
     * @param v new value
     */
    public void setUnits(int v) 
    {
    
                  if (this.units != v)
              {
            this.units = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Offered
     *
     * @return int
     */
    public int getOffered()
    {
        return offered;
    }

                        
    /**
     * Set the value of Offered
     *
     * @param v new value
     */
    public void setOffered(int v) 
    {
    
                  if (this.offered != v)
              {
            this.offered = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the SemesterOffered
     *
     * @return String
     */
    public String getSemesterOffered()
    {
        return semesterOffered;
    }

                        
    /**
     * Set the value of SemesterOffered
     *
     * @param v new value
     */
    public void setSemesterOffered(String v) 
    {
    
                  if (!ObjectUtils.equals(this.semesterOffered, v))
              {
            this.semesterOffered = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Prerequisite
     *
     * @return String
     */
    public String getPrerequisite()
    {
        return prerequisite;
    }

                        
    /**
     * Set the value of Prerequisite
     *
     * @param v new value
     */
    public void setPrerequisite(String v) 
    {
    
                  if (!ObjectUtils.equals(this.prerequisite, v))
              {
            this.prerequisite = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LectureHoursPerWeek
     *
     * @return int
     */
    public int getLectureHoursPerWeek()
    {
        return lectureHoursPerWeek;
    }

                        
    /**
     * Set the value of LectureHoursPerWeek
     *
     * @param v new value
     */
    public void setLectureHoursPerWeek(int v) 
    {
    
                  if (this.lectureHoursPerWeek != v)
              {
            this.lectureHoursPerWeek = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the MinimumNumberOfLectureStudents
     *
     * @return int
     */
    public int getMinimumNumberOfLectureStudents()
    {
        return minimumNumberOfLectureStudents;
    }

                        
    /**
     * Set the value of MinimumNumberOfLectureStudents
     *
     * @param v new value
     */
    public void setMinimumNumberOfLectureStudents(int v) 
    {
    
                  if (this.minimumNumberOfLectureStudents != v)
              {
            this.minimumNumberOfLectureStudents = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the MaximumNumberOfLectureStudents
     *
     * @return int
     */
    public int getMaximumNumberOfLectureStudents()
    {
        return maximumNumberOfLectureStudents;
    }

                        
    /**
     * Set the value of MaximumNumberOfLectureStudents
     *
     * @param v new value
     */
    public void setMaximumNumberOfLectureStudents(int v) 
    {
    
                  if (this.maximumNumberOfLectureStudents != v)
              {
            this.maximumNumberOfLectureStudents = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the HasLaboratory
     *
     * @return int
     */
    public int getHasLaboratory()
    {
        return hasLaboratory;
    }

                        
    /**
     * Set the value of HasLaboratory
     *
     * @param v new value
     */
    public void setHasLaboratory(int v) 
    {
    
                  if (this.hasLaboratory != v)
              {
            this.hasLaboratory = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LaboratoryHoursPerWeek
     *
     * @return int
     */
    public int getLaboratoryHoursPerWeek()
    {
        return laboratoryHoursPerWeek;
    }

                        
    /**
     * Set the value of LaboratoryHoursPerWeek
     *
     * @param v new value
     */
    public void setLaboratoryHoursPerWeek(int v) 
    {
    
                  if (this.laboratoryHoursPerWeek != v)
              {
            this.laboratoryHoursPerWeek = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the MinimumNumberOfLaboratoryStudents
     *
     * @return int
     */
    public int getMinimumNumberOfLaboratoryStudents()
    {
        return minimumNumberOfLaboratoryStudents;
    }

                        
    /**
     * Set the value of MinimumNumberOfLaboratoryStudents
     *
     * @param v new value
     */
    public void setMinimumNumberOfLaboratoryStudents(int v) 
    {
    
                  if (this.minimumNumberOfLaboratoryStudents != v)
              {
            this.minimumNumberOfLaboratoryStudents = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the MaximumNumberOfLaboratoryStudents
     *
     * @return int
     */
    public int getMaximumNumberOfLaboratoryStudents()
    {
        return maximumNumberOfLaboratoryStudents;
    }

                        
    /**
     * Set the value of MaximumNumberOfLaboratoryStudents
     *
     * @param v new value
     */
    public void setMaximumNumberOfLaboratoryStudents(int v) 
    {
    
                  if (this.maximumNumberOfLaboratoryStudents != v)
              {
            this.maximumNumberOfLaboratoryStudents = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the UnitId
     *
     * @return int
     */
    public int getUnitId()
    {
        return unitId;
    }

                              
    /**
     * Set the value of UnitId
     *
     * @param v new value
     */
    public void setUnitId(int v) throws TorqueException
    {
    
                  if (this.unitId != v)
              {
            this.unitId = v;
            setModified(true);
        }
    
                          
                if (aUnit != null && !(aUnit.getUnitId() == v))
                {
            aUnit = null;
        }
      
              }
  
      
    
                  
    
        private Unit aUnit;

    /**
     * Declares an association between this object and a Unit object
     *
     * @param v Unit
     * @throws TorqueException
     */
    public void setUnit(Unit v) throws TorqueException
    {
            if (v == null)
        {
                    setUnitId(0);
                  }
        else
        {
            setUnitId(v.getUnitId());
        }
                aUnit = v;
    }

                                            
    /**
     * Get the associated Unit object
     *
     * @return the associated Unit object
     * @throws TorqueException
     */
    public Unit getUnit() throws TorqueException
    {
        if (aUnit == null && (this.unitId > 0))
        {
                          aUnit = UnitPeer.retrieveByPK(SimpleKey.keyFor(this.unitId));
              
            /* The following can be used instead of the line above to
               guarantee the related object contains a reference
               to this object, but this level of coupling
               may be undesirable in many circumstances.
               As it can lead to a db query with many results that may
               never be used.
               Unit obj = UnitPeer.retrieveByPK(this.unitId);
               obj.addCourses(this);
            */
        }
        return aUnit;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey.  e.g.
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
           */
    public void setUnitKey(ObjectKey key) throws TorqueException
    {
      
                        setUnitId(((NumberKey) key).intValue());
                  }
       
                                
            
    /**
     * Collection to store aggregation of collCurriculumCourses
     */
    protected List collCurriculumCourses;

    /**
     * Temporary storage of collCurriculumCourses to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initCurriculumCourses()
    {
        if (collCurriculumCourses == null)
        {
            collCurriculumCourses = new ArrayList();
        }
    }

    /**
     * Method called to associate a CurriculumCourse object to this object
     * through the CurriculumCourse foreign key attribute
     *
     * @param l CurriculumCourse
     * @throws TorqueException
     */
    public void addCurriculumCourse(CurriculumCourse l) throws TorqueException
    {
        getCurriculumCourses().add(l);
        l.setCourse((Course) this);
    }

    /**
     * The criteria used to select the current contents of collCurriculumCourses
     */
    private Criteria lastCurriculumCoursesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCurriculumCourses(new Criteria())
     *
     * @throws TorqueException
     */
    public List getCurriculumCourses() throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            collCurriculumCourses = getCurriculumCourses(new Criteria(10));
        }
        return collCurriculumCourses;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getCurriculumCourses(Criteria criteria) throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                      criteria.add(CurriculumCoursePeer.COURSEID, getCourseId() );
                      collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(CurriculumCoursePeer.COURSEID, getCourseId());
                      if (!lastCurriculumCoursesCriteria.equals(criteria))
                {
                    collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria);
                }
            }
        }
        lastCurriculumCoursesCriteria = criteria;

        return collCurriculumCourses;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCurriculumCourses(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCurriculumCourses(Connection con) throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            collCurriculumCourses = getCurriculumCourses(new Criteria(10), con);
        }
        return collCurriculumCourses;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCurriculumCourses(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                       criteria.add(CurriculumCoursePeer.COURSEID, getCourseId());
                       collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(CurriculumCoursePeer.COURSEID, getCourseId());
                       if (!lastCurriculumCoursesCriteria.equals(criteria))
                 {
                     collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria, con);
                 }
             }
         }
         lastCurriculumCoursesCriteria = criteria;

         return collCurriculumCourses;
     }

                        
              
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getCurriculumCoursesJoinCurriculum(Criteria criteria)
        throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                            criteria.add(CurriculumCoursePeer.COURSEID, getCourseId());
                            collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCurriculum(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(CurriculumCoursePeer.COURSEID, getCourseId());
                        if (!lastCurriculumCoursesCriteria.equals(criteria))
            {
                collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCurriculum(criteria);
            }
        }
        lastCurriculumCoursesCriteria = criteria;

        return collCurriculumCourses;
    }
                  
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getCurriculumCoursesJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                            criteria.add(CurriculumCoursePeer.COURSEID, getCourseId());
                            collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(CurriculumCoursePeer.COURSEID, getCourseId());
                        if (!lastCurriculumCoursesCriteria.equals(criteria))
            {
                collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCourse(criteria);
            }
        }
        lastCurriculumCoursesCriteria = criteria;

        return collCurriculumCourses;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collSectionConfigurations
     */
    protected List collSectionConfigurations;

    /**
     * Temporary storage of collSectionConfigurations to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initSectionConfigurations()
    {
        if (collSectionConfigurations == null)
        {
            collSectionConfigurations = new ArrayList();
        }
    }

    /**
     * Method called to associate a SectionConfiguration object to this object
     * through the SectionConfiguration foreign key attribute
     *
     * @param l SectionConfiguration
     * @throws TorqueException
     */
    public void addSectionConfiguration(SectionConfiguration l) throws TorqueException
    {
        getSectionConfigurations().add(l);
        l.setCourse((Course) this);
    }

    /**
     * The criteria used to select the current contents of collSectionConfigurations
     */
    private Criteria lastSectionConfigurationsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getSectionConfigurations(new Criteria())
     *
     * @throws TorqueException
     */
    public List getSectionConfigurations() throws TorqueException
    {
        if (collSectionConfigurations == null)
        {
            collSectionConfigurations = getSectionConfigurations(new Criteria(10));
        }
        return collSectionConfigurations;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related SectionConfigurations from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getSectionConfigurations(Criteria criteria) throws TorqueException
    {
        if (collSectionConfigurations == null)
        {
            if (isNew())
            {
               collSectionConfigurations = new ArrayList();
            }
            else
            {
                      criteria.add(SectionConfigurationPeer.COURSEID, getCourseId() );
                      collSectionConfigurations = SectionConfigurationPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(SectionConfigurationPeer.COURSEID, getCourseId());
                      if (!lastSectionConfigurationsCriteria.equals(criteria))
                {
                    collSectionConfigurations = SectionConfigurationPeer.doSelect(criteria);
                }
            }
        }
        lastSectionConfigurationsCriteria = criteria;

        return collSectionConfigurations;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getSectionConfigurations(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getSectionConfigurations(Connection con) throws TorqueException
    {
        if (collSectionConfigurations == null)
        {
            collSectionConfigurations = getSectionConfigurations(new Criteria(10), con);
        }
        return collSectionConfigurations;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related SectionConfigurations from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getSectionConfigurations(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collSectionConfigurations == null)
        {
            if (isNew())
            {
               collSectionConfigurations = new ArrayList();
            }
            else
            {
                       criteria.add(SectionConfigurationPeer.COURSEID, getCourseId());
                       collSectionConfigurations = SectionConfigurationPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(SectionConfigurationPeer.COURSEID, getCourseId());
                       if (!lastSectionConfigurationsCriteria.equals(criteria))
                 {
                     collSectionConfigurations = SectionConfigurationPeer.doSelect(criteria, con);
                 }
             }
         }
         lastSectionConfigurationsCriteria = criteria;

         return collSectionConfigurations;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related SectionConfigurations from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getSectionConfigurationsJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collSectionConfigurations == null)
        {
            if (isNew())
            {
               collSectionConfigurations = new ArrayList();
            }
            else
            {
                            criteria.add(SectionConfigurationPeer.COURSEID, getCourseId());
                            collSectionConfigurations = SectionConfigurationPeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(SectionConfigurationPeer.COURSEID, getCourseId());
                        if (!lastSectionConfigurationsCriteria.equals(criteria))
            {
                collSectionConfigurations = SectionConfigurationPeer.doSelectJoinCourse(criteria);
            }
        }
        lastSectionConfigurationsCriteria = criteria;

        return collSectionConfigurations;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collPlanOfCourseWorks
     */
    protected List collPlanOfCourseWorks;

    /**
     * Temporary storage of collPlanOfCourseWorks to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initPlanOfCourseWorks()
    {
        if (collPlanOfCourseWorks == null)
        {
            collPlanOfCourseWorks = new ArrayList();
        }
    }

    /**
     * Method called to associate a PlanOfCourseWork object to this object
     * through the PlanOfCourseWork foreign key attribute
     *
     * @param l PlanOfCourseWork
     * @throws TorqueException
     */
    public void addPlanOfCourseWork(PlanOfCourseWork l) throws TorqueException
    {
        getPlanOfCourseWorks().add(l);
        l.setCourse((Course) this);
    }

    /**
     * The criteria used to select the current contents of collPlanOfCourseWorks
     */
    private Criteria lastPlanOfCourseWorksCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getPlanOfCourseWorks(new Criteria())
     *
     * @throws TorqueException
     */
    public List getPlanOfCourseWorks() throws TorqueException
    {
        if (collPlanOfCourseWorks == null)
        {
            collPlanOfCourseWorks = getPlanOfCourseWorks(new Criteria(10));
        }
        return collPlanOfCourseWorks;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related PlanOfCourseWorks from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getPlanOfCourseWorks(Criteria criteria) throws TorqueException
    {
        if (collPlanOfCourseWorks == null)
        {
            if (isNew())
            {
               collPlanOfCourseWorks = new ArrayList();
            }
            else
            {
                      criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId() );
                      collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId());
                      if (!lastPlanOfCourseWorksCriteria.equals(criteria))
                {
                    collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelect(criteria);
                }
            }
        }
        lastPlanOfCourseWorksCriteria = criteria;

        return collPlanOfCourseWorks;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getPlanOfCourseWorks(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getPlanOfCourseWorks(Connection con) throws TorqueException
    {
        if (collPlanOfCourseWorks == null)
        {
            collPlanOfCourseWorks = getPlanOfCourseWorks(new Criteria(10), con);
        }
        return collPlanOfCourseWorks;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related PlanOfCourseWorks from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getPlanOfCourseWorks(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collPlanOfCourseWorks == null)
        {
            if (isNew())
            {
               collPlanOfCourseWorks = new ArrayList();
            }
            else
            {
                       criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId());
                       collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId());
                       if (!lastPlanOfCourseWorksCriteria.equals(criteria))
                 {
                     collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelect(criteria, con);
                 }
             }
         }
         lastPlanOfCourseWorksCriteria = criteria;

         return collPlanOfCourseWorks;
     }

                        
              
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related PlanOfCourseWorks from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getPlanOfCourseWorksJoinStudent(Criteria criteria)
        throws TorqueException
    {
        if (collPlanOfCourseWorks == null)
        {
            if (isNew())
            {
               collPlanOfCourseWorks = new ArrayList();
            }
            else
            {
                            criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId());
                            collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelectJoinStudent(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId());
                        if (!lastPlanOfCourseWorksCriteria.equals(criteria))
            {
                collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelectJoinStudent(criteria);
            }
        }
        lastPlanOfCourseWorksCriteria = criteria;

        return collPlanOfCourseWorks;
    }
                  
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related PlanOfCourseWorks from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getPlanOfCourseWorksJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collPlanOfCourseWorks == null)
        {
            if (isNew())
            {
               collPlanOfCourseWorks = new ArrayList();
            }
            else
            {
                            criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId());
                            collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(PlanOfCourseWorkPeer.COURSEID, getCourseId());
                        if (!lastPlanOfCourseWorksCriteria.equals(criteria))
            {
                collPlanOfCourseWorks = PlanOfCourseWorkPeer.doSelectJoinCourse(criteria);
            }
        }
        lastPlanOfCourseWorksCriteria = criteria;

        return collPlanOfCourseWorks;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collGrades
     */
    protected List collGrades;

    /**
     * Temporary storage of collGrades to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initGrades()
    {
        if (collGrades == null)
        {
            collGrades = new ArrayList();
        }
    }

    /**
     * Method called to associate a Grade object to this object
     * through the Grade foreign key attribute
     *
     * @param l Grade
     * @throws TorqueException
     */
    public void addGrade(Grade l) throws TorqueException
    {
        getGrades().add(l);
        l.setCourse((Course) this);
    }

    /**
     * The criteria used to select the current contents of collGrades
     */
    private Criteria lastGradesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getGrades(new Criteria())
     *
     * @throws TorqueException
     */
    public List getGrades() throws TorqueException
    {
        if (collGrades == null)
        {
            collGrades = getGrades(new Criteria(10));
        }
        return collGrades;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related Grades from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getGrades(Criteria criteria) throws TorqueException
    {
        if (collGrades == null)
        {
            if (isNew())
            {
               collGrades = new ArrayList();
            }
            else
            {
                      criteria.add(GradePeer.COURSEID, getCourseId() );
                      collGrades = GradePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(GradePeer.COURSEID, getCourseId());
                      if (!lastGradesCriteria.equals(criteria))
                {
                    collGrades = GradePeer.doSelect(criteria);
                }
            }
        }
        lastGradesCriteria = criteria;

        return collGrades;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getGrades(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getGrades(Connection con) throws TorqueException
    {
        if (collGrades == null)
        {
            collGrades = getGrades(new Criteria(10), con);
        }
        return collGrades;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related Grades from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getGrades(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collGrades == null)
        {
            if (isNew())
            {
               collGrades = new ArrayList();
            }
            else
            {
                       criteria.add(GradePeer.COURSEID, getCourseId());
                       collGrades = GradePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(GradePeer.COURSEID, getCourseId());
                       if (!lastGradesCriteria.equals(criteria))
                 {
                     collGrades = GradePeer.doSelect(criteria, con);
                 }
             }
         }
         lastGradesCriteria = criteria;

         return collGrades;
     }

                        
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related Grades from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getGradesJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collGrades == null)
        {
            if (isNew())
            {
               collGrades = new ArrayList();
            }
            else
            {
                            criteria.add(GradePeer.COURSEID, getCourseId());
                            collGrades = GradePeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(GradePeer.COURSEID, getCourseId());
                        if (!lastGradesCriteria.equals(criteria))
            {
                collGrades = GradePeer.doSelectJoinCourse(criteria);
            }
        }
        lastGradesCriteria = criteria;

        return collGrades;
    }
                  
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related Grades from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getGradesJoinStudent(Criteria criteria)
        throws TorqueException
    {
        if (collGrades == null)
        {
            if (isNew())
            {
               collGrades = new ArrayList();
            }
            else
            {
                            criteria.add(GradePeer.COURSEID, getCourseId());
                            collGrades = GradePeer.doSelectJoinStudent(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(GradePeer.COURSEID, getCourseId());
                        if (!lastGradesCriteria.equals(criteria))
            {
                collGrades = GradePeer.doSelectJoinStudent(criteria);
            }
        }
        lastGradesCriteria = criteria;

        return collGrades;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collCourseDemands
     */
    protected List collCourseDemands;

    /**
     * Temporary storage of collCourseDemands to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initCourseDemands()
    {
        if (collCourseDemands == null)
        {
            collCourseDemands = new ArrayList();
        }
    }

    /**
     * Method called to associate a CourseDemand object to this object
     * through the CourseDemand foreign key attribute
     *
     * @param l CourseDemand
     * @throws TorqueException
     */
    public void addCourseDemand(CourseDemand l) throws TorqueException
    {
        getCourseDemands().add(l);
        l.setCourse((Course) this);
    }

    /**
     * The criteria used to select the current contents of collCourseDemands
     */
    private Criteria lastCourseDemandsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCourseDemands(new Criteria())
     *
     * @throws TorqueException
     */
    public List getCourseDemands() throws TorqueException
    {
        if (collCourseDemands == null)
        {
            collCourseDemands = getCourseDemands(new Criteria(10));
        }
        return collCourseDemands;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related CourseDemands from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getCourseDemands(Criteria criteria) throws TorqueException
    {
        if (collCourseDemands == null)
        {
            if (isNew())
            {
               collCourseDemands = new ArrayList();
            }
            else
            {
                      criteria.add(CourseDemandPeer.COURSEID, getCourseId() );
                      collCourseDemands = CourseDemandPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(CourseDemandPeer.COURSEID, getCourseId());
                      if (!lastCourseDemandsCriteria.equals(criteria))
                {
                    collCourseDemands = CourseDemandPeer.doSelect(criteria);
                }
            }
        }
        lastCourseDemandsCriteria = criteria;

        return collCourseDemands;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCourseDemands(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCourseDemands(Connection con) throws TorqueException
    {
        if (collCourseDemands == null)
        {
            collCourseDemands = getCourseDemands(new Criteria(10), con);
        }
        return collCourseDemands;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related CourseDemands from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCourseDemands(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collCourseDemands == null)
        {
            if (isNew())
            {
               collCourseDemands = new ArrayList();
            }
            else
            {
                       criteria.add(CourseDemandPeer.COURSEID, getCourseId());
                       collCourseDemands = CourseDemandPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(CourseDemandPeer.COURSEID, getCourseId());
                       if (!lastCourseDemandsCriteria.equals(criteria))
                 {
                     collCourseDemands = CourseDemandPeer.doSelect(criteria, con);
                 }
             }
         }
         lastCourseDemandsCriteria = criteria;

         return collCourseDemands;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related CourseDemands from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getCourseDemandsJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collCourseDemands == null)
        {
            if (isNew())
            {
               collCourseDemands = new ArrayList();
            }
            else
            {
                            criteria.add(CourseDemandPeer.COURSEID, getCourseId());
                            collCourseDemands = CourseDemandPeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(CourseDemandPeer.COURSEID, getCourseId());
                        if (!lastCourseDemandsCriteria.equals(criteria))
            {
                collCourseDemands = CourseDemandPeer.doSelectJoinCourse(criteria);
            }
        }
        lastCourseDemandsCriteria = criteria;

        return collCourseDemands;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collCourseOfferings
     */
    protected List collCourseOfferings;

    /**
     * Temporary storage of collCourseOfferings to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initCourseOfferings()
    {
        if (collCourseOfferings == null)
        {
            collCourseOfferings = new ArrayList();
        }
    }

    /**
     * Method called to associate a CourseOffering object to this object
     * through the CourseOffering foreign key attribute
     *
     * @param l CourseOffering
     * @throws TorqueException
     */
    public void addCourseOffering(CourseOffering l) throws TorqueException
    {
        getCourseOfferings().add(l);
        l.setCourse((Course) this);
    }

    /**
     * The criteria used to select the current contents of collCourseOfferings
     */
    private Criteria lastCourseOfferingsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCourseOfferings(new Criteria())
     *
     * @throws TorqueException
     */
    public List getCourseOfferings() throws TorqueException
    {
        if (collCourseOfferings == null)
        {
            collCourseOfferings = getCourseOfferings(new Criteria(10));
        }
        return collCourseOfferings;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related CourseOfferings from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getCourseOfferings(Criteria criteria) throws TorqueException
    {
        if (collCourseOfferings == null)
        {
            if (isNew())
            {
               collCourseOfferings = new ArrayList();
            }
            else
            {
                      criteria.add(CourseOfferingPeer.COURSEID, getCourseId() );
                      collCourseOfferings = CourseOfferingPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(CourseOfferingPeer.COURSEID, getCourseId());
                      if (!lastCourseOfferingsCriteria.equals(criteria))
                {
                    collCourseOfferings = CourseOfferingPeer.doSelect(criteria);
                }
            }
        }
        lastCourseOfferingsCriteria = criteria;

        return collCourseOfferings;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCourseOfferings(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCourseOfferings(Connection con) throws TorqueException
    {
        if (collCourseOfferings == null)
        {
            collCourseOfferings = getCourseOfferings(new Criteria(10), con);
        }
        return collCourseOfferings;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related CourseOfferings from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCourseOfferings(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collCourseOfferings == null)
        {
            if (isNew())
            {
               collCourseOfferings = new ArrayList();
            }
            else
            {
                       criteria.add(CourseOfferingPeer.COURSEID, getCourseId());
                       collCourseOfferings = CourseOfferingPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(CourseOfferingPeer.COURSEID, getCourseId());
                       if (!lastCourseOfferingsCriteria.equals(criteria))
                 {
                     collCourseOfferings = CourseOfferingPeer.doSelect(criteria, con);
                 }
             }
         }
         lastCourseOfferingsCriteria = criteria;

         return collCourseOfferings;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related CourseOfferings from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getCourseOfferingsJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collCourseOfferings == null)
        {
            if (isNew())
            {
               collCourseOfferings = new ArrayList();
            }
            else
            {
                            criteria.add(CourseOfferingPeer.COURSEID, getCourseId());
                            collCourseOfferings = CourseOfferingPeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(CourseOfferingPeer.COURSEID, getCourseId());
                        if (!lastCourseOfferingsCriteria.equals(criteria))
            {
                collCourseOfferings = CourseOfferingPeer.doSelectJoinCourse(criteria);
            }
        }
        lastCourseOfferingsCriteria = criteria;

        return collCourseOfferings;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collRecommendedCourses
     */
    protected List collRecommendedCourses;

    /**
     * Temporary storage of collRecommendedCourses to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initRecommendedCourses()
    {
        if (collRecommendedCourses == null)
        {
            collRecommendedCourses = new ArrayList();
        }
    }

    /**
     * Method called to associate a RecommendedCourse object to this object
     * through the RecommendedCourse foreign key attribute
     *
     * @param l RecommendedCourse
     * @throws TorqueException
     */
    public void addRecommendedCourse(RecommendedCourse l) throws TorqueException
    {
        getRecommendedCourses().add(l);
        l.setCourse((Course) this);
    }

    /**
     * The criteria used to select the current contents of collRecommendedCourses
     */
    private Criteria lastRecommendedCoursesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getRecommendedCourses(new Criteria())
     *
     * @throws TorqueException
     */
    public List getRecommendedCourses() throws TorqueException
    {
        if (collRecommendedCourses == null)
        {
            collRecommendedCourses = getRecommendedCourses(new Criteria(10));
        }
        return collRecommendedCourses;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related RecommendedCourses from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getRecommendedCourses(Criteria criteria) throws TorqueException
    {
        if (collRecommendedCourses == null)
        {
            if (isNew())
            {
               collRecommendedCourses = new ArrayList();
            }
            else
            {
                      criteria.add(RecommendedCoursePeer.COURSEID, getCourseId() );
                      collRecommendedCourses = RecommendedCoursePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(RecommendedCoursePeer.COURSEID, getCourseId());
                      if (!lastRecommendedCoursesCriteria.equals(criteria))
                {
                    collRecommendedCourses = RecommendedCoursePeer.doSelect(criteria);
                }
            }
        }
        lastRecommendedCoursesCriteria = criteria;

        return collRecommendedCourses;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getRecommendedCourses(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getRecommendedCourses(Connection con) throws TorqueException
    {
        if (collRecommendedCourses == null)
        {
            collRecommendedCourses = getRecommendedCourses(new Criteria(10), con);
        }
        return collRecommendedCourses;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course has previously
     * been saved, it will retrieve related RecommendedCourses from storage.
     * If this Course is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getRecommendedCourses(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collRecommendedCourses == null)
        {
            if (isNew())
            {
               collRecommendedCourses = new ArrayList();
            }
            else
            {
                       criteria.add(RecommendedCoursePeer.COURSEID, getCourseId());
                       collRecommendedCourses = RecommendedCoursePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(RecommendedCoursePeer.COURSEID, getCourseId());
                       if (!lastRecommendedCoursesCriteria.equals(criteria))
                 {
                     collRecommendedCourses = RecommendedCoursePeer.doSelect(criteria, con);
                 }
             }
         }
         lastRecommendedCoursesCriteria = criteria;

         return collRecommendedCourses;
     }

                        
              
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related RecommendedCourses from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getRecommendedCoursesJoinStudent(Criteria criteria)
        throws TorqueException
    {
        if (collRecommendedCourses == null)
        {
            if (isNew())
            {
               collRecommendedCourses = new ArrayList();
            }
            else
            {
                            criteria.add(RecommendedCoursePeer.COURSEID, getCourseId());
                            collRecommendedCourses = RecommendedCoursePeer.doSelectJoinStudent(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(RecommendedCoursePeer.COURSEID, getCourseId());
                        if (!lastRecommendedCoursesCriteria.equals(criteria))
            {
                collRecommendedCourses = RecommendedCoursePeer.doSelectJoinStudent(criteria);
            }
        }
        lastRecommendedCoursesCriteria = criteria;

        return collRecommendedCourses;
    }
                  
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Course is new, it will return
     * an empty collection; or if this Course has previously
     * been saved, it will retrieve related RecommendedCourses from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Course.
     */
    protected List getRecommendedCoursesJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collRecommendedCourses == null)
        {
            if (isNew())
            {
               collRecommendedCourses = new ArrayList();
            }
            else
            {
                            criteria.add(RecommendedCoursePeer.COURSEID, getCourseId());
                            collRecommendedCourses = RecommendedCoursePeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(RecommendedCoursePeer.COURSEID, getCourseId());
                        if (!lastRecommendedCoursesCriteria.equals(criteria))
            {
                collRecommendedCourses = RecommendedCoursePeer.doSelectJoinCourse(criteria);
            }
        }
        lastRecommendedCoursesCriteria = criteria;

        return collRecommendedCourses;
    }
                            


          
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
              fieldNames.add("CourseId");
              fieldNames.add("CourseCode");
              fieldNames.add("CourseName");
              fieldNames.add("CourseDescription");
              fieldNames.add("Units");
              fieldNames.add("Offered");
              fieldNames.add("SemesterOffered");
              fieldNames.add("Prerequisite");
              fieldNames.add("LectureHoursPerWeek");
              fieldNames.add("MinimumNumberOfLectureStudents");
              fieldNames.add("MaximumNumberOfLectureStudents");
              fieldNames.add("HasLaboratory");
              fieldNames.add("LaboratoryHoursPerWeek");
              fieldNames.add("MinimumNumberOfLaboratoryStudents");
              fieldNames.add("MaximumNumberOfLaboratoryStudents");
              fieldNames.add("UnitId");
              fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
          if (name.equals("CourseId"))
        {
                return new Integer(getCourseId());
            }
          if (name.equals("CourseCode"))
        {
                return getCourseCode();
            }
          if (name.equals("CourseName"))
        {
                return getCourseName();
            }
          if (name.equals("CourseDescription"))
        {
                return getCourseDescription();
            }
          if (name.equals("Units"))
        {
                return new Integer(getUnits());
            }
          if (name.equals("Offered"))
        {
                return new Integer(getOffered());
            }
          if (name.equals("SemesterOffered"))
        {
                return getSemesterOffered();
            }
          if (name.equals("Prerequisite"))
        {
                return getPrerequisite();
            }
          if (name.equals("LectureHoursPerWeek"))
        {
                return new Integer(getLectureHoursPerWeek());
            }
          if (name.equals("MinimumNumberOfLectureStudents"))
        {
                return new Integer(getMinimumNumberOfLectureStudents());
            }
          if (name.equals("MaximumNumberOfLectureStudents"))
        {
                return new Integer(getMaximumNumberOfLectureStudents());
            }
          if (name.equals("HasLaboratory"))
        {
                return new Integer(getHasLaboratory());
            }
          if (name.equals("LaboratoryHoursPerWeek"))
        {
                return new Integer(getLaboratoryHoursPerWeek());
            }
          if (name.equals("MinimumNumberOfLaboratoryStudents"))
        {
                return new Integer(getMinimumNumberOfLaboratoryStudents());
            }
          if (name.equals("MaximumNumberOfLaboratoryStudents"))
        {
                return new Integer(getMaximumNumberOfLaboratoryStudents());
            }
          if (name.equals("UnitId"))
        {
                return new Integer(getUnitId());
            }
          return null;
    }
    
    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
          if (name.equals(CoursePeer.COURSEID))
        {
                return new Integer(getCourseId());
            }
          if (name.equals(CoursePeer.COURSECODE))
        {
                return getCourseCode();
            }
          if (name.equals(CoursePeer.COURSENAME))
        {
                return getCourseName();
            }
          if (name.equals(CoursePeer.COURSEDESCRIPTION))
        {
                return getCourseDescription();
            }
          if (name.equals(CoursePeer.UNITS))
        {
                return new Integer(getUnits());
            }
          if (name.equals(CoursePeer.OFFERED))
        {
                return new Integer(getOffered());
            }
          if (name.equals(CoursePeer.SEMESTEROFFERED))
        {
                return getSemesterOffered();
            }
          if (name.equals(CoursePeer.PREREQUISITE))
        {
                return getPrerequisite();
            }
          if (name.equals(CoursePeer.LECTUREHOURSPERWEEK))
        {
                return new Integer(getLectureHoursPerWeek());
            }
          if (name.equals(CoursePeer.MINIMUMNUMBEROFLECTURESTUDENTS))
        {
                return new Integer(getMinimumNumberOfLectureStudents());
            }
          if (name.equals(CoursePeer.MAXIMUMNUMBEROFLECTURESTUDENTS))
        {
                return new Integer(getMaximumNumberOfLectureStudents());
            }
          if (name.equals(CoursePeer.HASLABORATORY))
        {
                return new Integer(getHasLaboratory());
            }
          if (name.equals(CoursePeer.LABORATORYHOURSPERWEEK))
        {
                return new Integer(getLaboratoryHoursPerWeek());
            }
          if (name.equals(CoursePeer.MINIMUMNUMBEROFLABORATORYSTUDENTS))
        {
                return new Integer(getMinimumNumberOfLaboratoryStudents());
            }
          if (name.equals(CoursePeer.MAXIMUMNUMBEROFLABORATORYSTUDENTS))
        {
                return new Integer(getMaximumNumberOfLaboratoryStudents());
            }
          if (name.equals(CoursePeer.UNITID))
        {
                return new Integer(getUnitId());
            }
          return null;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
            if (pos == 0)
        {
                return new Integer(getCourseId());
            }
              if (pos == 1)
        {
                return getCourseCode();
            }
              if (pos == 2)
        {
                return getCourseName();
            }
              if (pos == 3)
        {
                return getCourseDescription();
            }
              if (pos == 4)
        {
                return new Integer(getUnits());
            }
              if (pos == 5)
        {
                return new Integer(getOffered());
            }
              if (pos == 6)
        {
                return getSemesterOffered();
            }
              if (pos == 7)
        {
                return getPrerequisite();
            }
              if (pos == 8)
        {
                return new Integer(getLectureHoursPerWeek());
            }
              if (pos == 9)
        {
                return new Integer(getMinimumNumberOfLectureStudents());
            }
              if (pos == 10)
        {
                return new Integer(getMaximumNumberOfLectureStudents());
            }
              if (pos == 11)
        {
                return new Integer(getHasLaboratory());
            }
              if (pos == 12)
        {
                return new Integer(getLaboratoryHoursPerWeek());
            }
              if (pos == 13)
        {
                return new Integer(getMinimumNumberOfLaboratoryStudents());
            }
              if (pos == 14)
        {
                return new Integer(getMaximumNumberOfLaboratoryStudents());
            }
              if (pos == 15)
        {
                return new Integer(getUnitId());
            }
              return null;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
          save(CoursePeer.getMapBuilder()
                .getDatabaseMap().getName());
      }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
       * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
       *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
          try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
      }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
          if (!alreadyInSave)
        {
            alreadyInSave = true;


  
            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    CoursePeer.doInsert((Course) this, con);
                    setNew(false);
                }
                else
                {
                    CoursePeer.doUpdate((Course) this, con);
                }
            }

                                      
                
            if (collCurriculumCourses != null)
            {
                for (int i = 0; i < collCurriculumCourses.size(); i++)
                {
                    ((CurriculumCourse) collCurriculumCourses.get(i)).save(con);
                }
            }
                                          
                
            if (collSectionConfigurations != null)
            {
                for (int i = 0; i < collSectionConfigurations.size(); i++)
                {
                    ((SectionConfiguration) collSectionConfigurations.get(i)).save(con);
                }
            }
                                          
                
            if (collPlanOfCourseWorks != null)
            {
                for (int i = 0; i < collPlanOfCourseWorks.size(); i++)
                {
                    ((PlanOfCourseWork) collPlanOfCourseWorks.get(i)).save(con);
                }
            }
                                          
                
            if (collGrades != null)
            {
                for (int i = 0; i < collGrades.size(); i++)
                {
                    ((Grade) collGrades.get(i)).save(con);
                }
            }
                                          
                
            if (collCourseDemands != null)
            {
                for (int i = 0; i < collCourseDemands.size(); i++)
                {
                    ((CourseDemand) collCourseDemands.get(i)).save(con);
                }
            }
                                          
                
            if (collCourseOfferings != null)
            {
                for (int i = 0; i < collCourseOfferings.size(); i++)
                {
                    ((CourseOffering) collCourseOfferings.get(i)).save(con);
                }
            }
                                          
                
            if (collRecommendedCourses != null)
            {
                for (int i = 0; i < collRecommendedCourses.size(); i++)
                {
                    ((RecommendedCourse) collRecommendedCourses.get(i)).save(con);
                }
            }
                          alreadyInSave = false;
        }
      }


                          
      /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param  courseId ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
            setCourseId(((NumberKey) key).intValue());
        }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
            setCourseId(Integer.parseInt(key));
        }

  
    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
          return SimpleKey.keyFor(getCourseId());
      }

 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
       * It then fills all the association collections and sets the
     * related objects to isNew=true.
       */
      public Course copy() throws TorqueException
    {
        return copyInto(new Course());
    }
  
    protected Course copyInto(Course copyObj) throws TorqueException
    {
          copyObj.setCourseId(courseId);
          copyObj.setCourseCode(courseCode);
          copyObj.setCourseName(courseName);
          copyObj.setCourseDescription(courseDescription);
          copyObj.setUnits(units);
          copyObj.setOffered(offered);
          copyObj.setSemesterOffered(semesterOffered);
          copyObj.setPrerequisite(prerequisite);
          copyObj.setLectureHoursPerWeek(lectureHoursPerWeek);
          copyObj.setMinimumNumberOfLectureStudents(minimumNumberOfLectureStudents);
          copyObj.setMaximumNumberOfLectureStudents(maximumNumberOfLectureStudents);
          copyObj.setHasLaboratory(hasLaboratory);
          copyObj.setLaboratoryHoursPerWeek(laboratoryHoursPerWeek);
          copyObj.setMinimumNumberOfLaboratoryStudents(minimumNumberOfLaboratoryStudents);
          copyObj.setMaximumNumberOfLaboratoryStudents(maximumNumberOfLaboratoryStudents);
          copyObj.setUnitId(unitId);
  
                    copyObj.setCourseId(0);
                                                                                                      
                                      
                
        List v = getCurriculumCourses();
        for (int i = 0; i < v.size(); i++)
        {
            CurriculumCourse obj = (CurriculumCourse) v.get(i);
            copyObj.addCurriculumCourse(obj.copy());
        }
                                                  
                
        v = getSectionConfigurations();
        for (int i = 0; i < v.size(); i++)
        {
            SectionConfiguration obj = (SectionConfiguration) v.get(i);
            copyObj.addSectionConfiguration(obj.copy());
        }
                                                  
                
        v = getPlanOfCourseWorks();
        for (int i = 0; i < v.size(); i++)
        {
            PlanOfCourseWork obj = (PlanOfCourseWork) v.get(i);
            copyObj.addPlanOfCourseWork(obj.copy());
        }
                                                  
                
        v = getGrades();
        for (int i = 0; i < v.size(); i++)
        {
            Grade obj = (Grade) v.get(i);
            copyObj.addGrade(obj.copy());
        }
                                                  
                
        v = getCourseDemands();
        for (int i = 0; i < v.size(); i++)
        {
            CourseDemand obj = (CourseDemand) v.get(i);
            copyObj.addCourseDemand(obj.copy());
        }
                                                  
                
        v = getCourseOfferings();
        for (int i = 0; i < v.size(); i++)
        {
            CourseOffering obj = (CourseOffering) v.get(i);
            copyObj.addCourseOffering(obj.copy());
        }
                                                  
                
        v = getRecommendedCourses();
        for (int i = 0; i < v.size(); i++)
        {
            RecommendedCourse obj = (RecommendedCourse) v.get(i);
            copyObj.addRecommendedCourse(obj.copy());
        }
                    
        return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public CoursePeer getPeer()
    {
        return peer;
    }

    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Course:\n");
        str.append("CourseId = ")
           .append(getCourseId())
           .append("\n");
        str.append("CourseCode = ")
           .append(getCourseCode())
           .append("\n");
        str.append("CourseName = ")
           .append(getCourseName())
           .append("\n");
        str.append("CourseDescription = ")
           .append(getCourseDescription())
           .append("\n");
        str.append("Units = ")
           .append(getUnits())
           .append("\n");
        str.append("Offered = ")
           .append(getOffered())
           .append("\n");
        str.append("SemesterOffered = ")
           .append(getSemesterOffered())
           .append("\n");
        str.append("Prerequisite = ")
           .append(getPrerequisite())
           .append("\n");
        str.append("LectureHoursPerWeek = ")
           .append(getLectureHoursPerWeek())
           .append("\n");
        str.append("MinimumNumberOfLectureStudents = ")
           .append(getMinimumNumberOfLectureStudents())
           .append("\n");
        str.append("MaximumNumberOfLectureStudents = ")
           .append(getMaximumNumberOfLectureStudents())
           .append("\n");
        str.append("HasLaboratory = ")
           .append(getHasLaboratory())
           .append("\n");
        str.append("LaboratoryHoursPerWeek = ")
           .append(getLaboratoryHoursPerWeek())
           .append("\n");
        str.append("MinimumNumberOfLaboratoryStudents = ")
           .append(getMinimumNumberOfLaboratoryStudents())
           .append("\n");
        str.append("MaximumNumberOfLaboratoryStudents = ")
           .append(getMaximumNumberOfLaboratoryStudents())
           .append("\n");
        str.append("UnitId = ")
           .append(getUnitId())
           .append("\n");
        return(str.toString());
    }
}
